<? 

require_once('html2fpdf.php');

include ('../includes/conf.php');

error_reporting(0);

$query = @$HTTP_GET_VARS["query"];
$report_name = @$HTTP_GET_VARS["name"];

if ($report_name=="") {
	$report_name="report";
}
$report_name = str_replace(" ", "_",$report_name);
//$query = "SELECT * FROM aliquote";
$resultID = mysql_query($query, $db) ;


// activate Output-Buffer:


//ob_start(); 

$pdf = new HTML2FPDF();
$pdf->DisableTags();
//$pdf->DisplayPreferences('FullScreen');


//echo $query;
 
$xml_output="<center><img src='logo.png' width=100%></center>";

$xml_output .="<table border=1 repeat_header=1>";
$xml_output .="<tr>";

for($y = 0 ; $y < mysql_num_fields($resultID) ; $y++){
	    $xml_output .= "<th>" . mysql_field_name($resultID, $y) . "</th>";
}

$xml_output .="</tr>";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
    $row = mysql_fetch_assoc($resultID);

    $xml_output .= "<tr>";

	for($y = 0 ; $y < mysql_num_fields($resultID) ; $y++){
	    $xml_output .= "<td>" . $row[mysql_field_name($resultID, $y)] . "</td>";
	}

    
    $xml_output .= "</tr>";
}

$xml_output .= "</table>";


//echo $xml_output;



$pdf->AddPage();
$pdf->WriteHTML($xml_output);
$pdf->Output($report_name.'.pdf','D'); 


?>

